package com.CmJava;

import com.CmJava.annotation.Autowired;
import com.CmJava.config.SpringConfiguration;
import com.CmJava.context.ApplicationContext;
import com.CmJava.controller.MyController;
import com.CmJava.service.MyService;
import com.CmJava.service.MyServiceImpl;
import com.CmJava.service.MyServiceLazyImpl;
import com.CmJava.service.MyServicePrototypeImpl;

public class Main {

    @Autowired
    private MyService myService;

    public static void main(String[] args) {
        //启动Spring，扫描，创建非懒加载的bean
        ApplicationContext applicationContext = new ApplicationContext(SpringConfiguration.class);

        MyService myService1 = (MyService) applicationContext.getBean("com.CmJava.service.MyServiceImpl");
        MyServiceLazyImpl myService2 = (MyServiceLazyImpl) applicationContext.getBean("com.CmJava.service.MyServiceLazyImpl");
        MyServiceLazyImpl myService3 = (MyServiceLazyImpl) applicationContext.getBean("com.CmJava.service.MyServiceLazyImpl");
        MyServicePrototypeImpl myService4 = (MyServicePrototypeImpl) applicationContext.getBean("com.CmJava.service.MyServicePrototypeImpl");
        MyServicePrototypeImpl myService5 = (MyServicePrototypeImpl) applicationContext.getBean("com.CmJava.service.MyServicePrototypeImpl");
        MyController myController = (MyController) applicationContext.getBean("com.CmJava.controller.MyController");
        System.out.println(myService1);
        System.out.println(myService2);
        System.out.println(myService3);
        System.out.println(myService4);
        System.out.println(myService5);
        System.out.println(myController);


        System.out.println("--------------AOP测试--------------");


        myService1.getUserName();
        myService1.getUserPassword();

        System.out.println("--------------API测试--------------");
        myService2.getUserName();
        myService3.getUserName();
        myService4.getUserName();
        myService5.getUserName();









    }
}
